<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="template">
<head th:replace="fragments/head::head"></head>
<body>
<th:block layout:fragment="content">

    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-16">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h4>物料别名新增</h4>
                        <div class="ibox-tools">
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t">
                            <!--物料基本信息-->
                            <div class="panel-title">
		                        <h5 style="color:#293846;">物料基本信息</h5>
		                    </div>
		                    <div class="form-group">
                                <label class="col-sm-1 control-label">公司信息：</label>
                                <div class="col-sm-2">
                                	<input type="hidden" skey="companyId" id="companyId" th:value="${companyId}" class="form-control formSubmit" /> 
                                    <input type="text" skey="companyName" id="companyName" th:value="${companyName}" readonly class="form-control formSubmit" />
                                    <!-- <select class="form-control input-sm formSubmit" skey="companyId">
                                        <option  value="-1">请选择公司</option>
                                        <option th:each="menuOne:${unitList}" th:value="${menuOne.id}" th:text="${menuOne.name}"></option>
                                    </select> -->
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">物料编码：</label>
                                <div class="col-sm-2">
                                    <!-- <input type="text" class="form-control formSubmit" skey="materialCoding" emsg="物料编码不能为空" th:value="${entity.materialCoding}"> -->
                                     <div class="input-group">
                                         <input type="hidden" skey="materialId" id="materialId" class="form-control formSubmit"  emsg="物料ID不能为空" readonly="readonly">
                                         <input type="text" skey="materialCoding" id="materialCoding" class="form-control formSubmit"  emsg="物料编码不能为空" readonly="readonly">  <span class="input-group-btn"> <input type="button" class="btn btn-primary " data-toggle="modal" data-target="#myModal" value="查找"></input>
                                         </span>
                                    </div>
                                </div>
                                <label class="col-sm-1 control-label">物料名称：</label>
                                <div class="col-sm-2">
                                    <!-- <input type="text" class="form-control formSubmit" skey="materialName" emsg="物料名称不能为空" th:value="${entity.materialName}"> -->
                                    <input type="text" class="form-control formSubmit" skey="materialName" id="materialName" emsg="物料名称不能为空"  readonly="readonly">
                                </div>
                                <label class="col-sm-1 control-label">物料规格：</label>
                                <div class="col-sm-2">
                                    <!-- <input type="text" class="form-control formSubmit" skey="materialSpec" th:value="${entity.materialSpec}" > -->
                                    <input type="text" class="form-control formSubmit" skey="materialSpec" id="materialSpec"  readonly="readonly">
                                </div>
                            </div>  
                            <div class="form-group">    
                                <label class="col-sm-1 control-label">物料类型：</label>
                                <div class="col-sm-2">
                                    <input type="hidden" class="form-control formSubmit" skey="materialTypeId"  id="materialTypeId"  readonly="readonly">
                                    <input type="text" class="form-control formSubmit" skey="materialType"  id="materialType"  readonly="readonly">
                                </div>
                                <label class="col-sm-1 control-label">计量单位：</label>
                                <div class="col-sm-2">
                                	<input type="hidden" class="form-control formSubmit" skey="measurementUId"  id="measurementUId"  readonly="readonly">
                                	<input type="text" class="form-control formSubmit" skey="measurementUName"  id="measurementUName"  readonly="readonly">
                                </div>
                                <label class="col-sm-1 control-label">品牌：</label>
                                <div class="col-sm-2">
                                    <input type="hidden" class="form-control formSubmit" skey="brandId"  id="brandId"  readonly="readonly">
                                    <input type="text" class="form-control formSubmit" skey="brandName"  id="brandName"  readonly="readonly">
                                </div>
                            </div>
                            <!--往来单位物料信息-->
                            <div class="panel-title">
		                        <h5 style="color:#293846;">往来单位物料信息</h5>
		                    </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">往来单位名称：</label>
                                <div class="col-sm-2">
                                    <!-- <input type="text" class="form-control formSubmit" skey="supplierCustomerId" emsg="往来单位名称不能为空" th:value="${entity.supplierCustomerId}"> -->
                                    <div class="input-group">
                                         <input type="hidden" skey="supplierCustomerId" id="supplierCustomerId"  readonly="readonly" class="form-control formSubmit">
                                         <input type="text" skey="supplierCustomerName" id="supplierCustomerName"  readonly="readonly" class="form-control formSubmit">  <span class="input-group-btn"> <input type="button" class="btn btn-primary " data-toggle="modal" data-target="#myModal_1" value="查找"></input>
                                         </span>
                                    </div>
                                </div>
                                <label class="col-sm-1 control-label">往来单位类型：</label>
                                <div class="col-sm-2">
                                    <!-- <input type="text" class="form-control formSubmit" skey="supplierCustomerType" th:value="${entity.supplierCustomerType}" > -->
                                    <input type="text" class="form-control formSubmit" skey="supplierCustomerTypeName"  id="supplierCustomerTypeName"  readonly="readonly">
                                    <input type="hidden" class="form-control formSubmit" skey="supplierCustomerType"  id="supplierCustomerType"  readonly="readonly">
                            	</div>
                            </div>
                                
                            <div class="form-group">
                                <label class="col-sm-1 control-label">往来存货编码：</label>
                                <div class="col-sm-2">
                                    <!-- <input type="text" class="form-control formSubmit" skey="scMaterialCoding" emsg="往来存货编码不能为空" th:value="${entity.scMaterialCoding}"> -->
                                    <input type="text" class="form-control formSubmit" skey="scMaterialCoding" id="scMaterialCoding" emsg="往来存货编码不能为空">
                                </div>
                                <label class="col-sm-1 control-label">往来存货名称：</label>
                                <div class="col-sm-2">
                                    <!-- <input type="text" class="form-control formSubmit" skey="scMaterialName" emsg="往来存货名称不能为空" th:value="${entity.scMaterialName}"> -->
                                    <input type="text" class="form-control formSubmit" skey="scMaterialName" id="scMaterialName"  emsg="往来存货名称不能为空">
                                </div>
                                <label class="col-sm-1 control-label">往来存货规格：</label>
                                <div class="col-sm-2">
                                    <!-- <input type="text" class="form-control formSubmit" skey="scMaterialSpec" th:value="${entity.scMaterialSpec}" > -->
                                    <input type="text" class="form-control formSubmit" skey="scMaterialSpec" id="scMaterialSpec">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-1 control-label">备注：</label>
                                <div class="col-sm-8">
                                    <input type="text"  class="form-control formSubmit" rows="3"  style="outline:none;resize:none;"  skey="remark">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary" type="button" onclick="saveMenu()">保存</button>
                                    <button class="btn btn-primary" type="button" onclick="history.go(-1);">返回</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 物料信息弹出层 -->    
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
        <div class="modal-dialog" style="width:1100px;height:2000px">
            <div class="modal-content">
            	<!-- 弹出层头部 -->
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">物料信息选择</h4>
                </div>
                <!-- 弹出层内容 -->
                <div class="modal-body">
                   <div class="hr-line-dashed m-t-sm m-b-sm"></div>
                   <div style="width:1000px;overflow-x:scroll;">
		            <table id="callbackgrid" ></table> 
		            <div id="callbackpager" ></div> 
		           </div>
                </div>
                <!-- 弹出层尾部 -->
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 往来单位弹出层 -->    
    <div class="modal fade" id="myModal_1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
        <div class="modal-dialog" style="width:1100px;height:2000px">
            <div class="modal-content">
            	<!-- 弹出层头部 -->
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">往来单位信息选择</h4>
                </div>
                <!-- 弹出层内容 -->
                <div class="modal-body">
                   <div class="hr-line-dashed m-t-sm m-b-sm"></div>
                   <div style="width:1000px;overflow-x:scroll;">
		            <table id="callbackgrid_1" ></table> 
		            <div id="callbackpager_1" ></div> 
		           </div>
                </div>
                <!-- 弹出层尾部 -->
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>

    <!--<div th:replace="/department/model::modelDiv"></div>-->
    <js th:replace="eng/materialalias/add/businessJs::businessJs"></js>
     <script>
     $(document).ready(function(){
    	 $(function(){ 
         	pageInit(); 
         	pageInit1(); 
         }); 
         function pageInit(){ 
         	var lastsel; 
         	 jQuery("#callbackgrid").jqGrid( {
         		//初始化页面时加载数据
         		url : '/eng/material/alias/data', 
         		//url : '/eng/material/info/data', 
         		//数据传输解析格式设置
         		datatype : "json", 
         		//页面加载样式
         		styleUI: 'Bootstrap',
         		//表头列名称
         		colNames : [ '物料ID', '物料编码', '物料名称', '物料规格', '物料类型ID', '物料类型', '计量单位ID', '计量单位', '品牌ID', '品牌'], 
         		//列模型属性配置
         		colModel : [ 
         		    {name : 'materialId',index : 'materialId',search:true,width:100,key:true,hidden:true},//主键       
         			//{name : 'companyId',index : 'companyId',search:true},//公司信息
         			{name : 'materialCoding',index : 'materialCoding',search:true,width:180}, //物料编码
         			{name : 'materialName',index : 'materialName',search:true,width:180}, //物料名称
         			{name : 'materialSpec',index : 'materialSpec',search:true,width:180},//物料规格
         			{name : 'materialTypeId',index : 'materialTypeId',hidden:true},//物料类型ID 
         			{name : 'materialType',index : 'materialType',search:true},//物料类型 
         			{name : 'measurementUId',index : 'measurementUId',hidden:true},//计量单位ID 
         			{name : 'measurementUName',index : 'measurementUName',search:true},//计量单位 
         			{name : 'brandId',index : 'brandId',hidden:true}, //品牌ID
         			{name : 'brandName',index : 'brandName',search:true} //品牌
         			],
         		//表格自适应宽度
         		autoWidth:true,
         		shrinkToFit: true,
         		//width:1000, 
         		//autoScroll: true,
             	height: 400,
         		//每页显示的条数
         		rowNum : 10,
         		//配置分页显示信息
         		rowList : [ 10, 20, 30 ], 
         		//绑定分页工具栏
         		pager : '#callbackpager', 
         		//用数组展示 可排序列
         		sortname : 'id', 
         		//显示当前网格数据条数
         		viewrecords : true, 
         		//排序方式 
         		sortorder : "desc", 
         		//multiselect: true,
         		altRows: true,  
                 rownumbers: true,
         		//编辑完成后向台提交
         		editurl : "/RowEditing", 
         		//网格标题
         		caption : "物料信息",
         		//网格双击事件
         		ondblClickRow: function (id){  
         			//id为当前行的 index
         			var rowData = $("#callbackgrid").jqGrid("getRowData",id);
         			//回填网格 物料编码
         			$("#materialId").val(rowData.materialId); 
         			//回填网格 物料编码
         			$("#materialCoding").val(rowData.materialCoding); 
         			//回填物料名称
         			$("#materialName").val(rowData.materialName); 
         			//回填物料规格
         			$("#materialSpec").val(rowData.materialSpec);
         			//回填物料类型
         			$("#materialTypeId").val(rowData.materialTypeId);
         			//回填物料类型
         			$("#materialType").val(rowData.materialType);
         			//设置计量单位id
         			$("#measurementUId").val(rowData.measurementUId);
         			//设置计量单位名称
         			$("#measurementUName").val(rowData.measurementUName);
         			//设置品牌id
         			$("#brandId").val(rowData.brandId);
         			//设置品牌名称
         			$("#brandName").val(rowData.brandName); 
         			
         			$("#myModal").modal('hide');
         		}
         	}); 
         	// 配置jqgrid 下方的导航信息
         	jQuery("#callbackgrid").jqGrid('navGrid', "#callbackpager", { edit : false, add : false, del : true, position: "left" },{},{},{},{multipleSearch:true});  
         	//下方为  官方API 示例  http://blog.mn886.net/jqGrid/
         	 //$("#callbackgrid").closest(".ui-jqgrid-bdiv").css({ 'overflow-x' : 'scroll' });
         };
         function pageInit1(){ 
          	var lastsel; 
          	 jQuery("#callbackgrid_1").jqGrid( {
          		//初始化页面时加载数据
          		url : '/eng/material/alias/partnerdata', 
          		//url : '/com/supplier/customer/data', 
          		//数据传输解析格式设置
          		datatype : "json", 
          		//页面加载样式
          		styleUI: 'Bootstrap',
          		//表头列名称
          		colNames : [ '往来单位ID', '往来单位名称', '往来单位类型','往来单位类型名称','备注'], 
          		//列模型属性配置
          		colModel : [ 
          		    {name : 'supplierCustomerId',index : 'supplierCustomerId',search:true,width:100,key:true,hidden:true}, //主键    
          			//{name : 'companyId',index : 'companyId',search:true}, //公司信息
          			{name : 'supplierCustomerName',index : 'supplierCustomerName',search:true,width:350}, //往来单位名称
          			{name : 'supplierCustomerType',index : 'supplierCustomerType',search:true,width:350,hidden:true},//往来单位类型
          			{name : 'supplierCustomerTypeName',index : 'supplierCustomerTypeName',search:true,width:350},//往来单位类型名称
          			{name : 'remark',index : 'remark',search:true,width:300}//备注
          			],
          		//表格自适应宽度
          		autoWidth:true,
          		shrinkToFit: true,
          		//width:1000, 
          		//autoScroll: true,
              	height: 400,
          		//每页显示的条数
          		rowNum : 10,
          		//配置分页显示信息
          		rowList : [ 10, 20, 30 ], 
          		//绑定分页工具栏
          		pager : '#callbackpager_1', 
          		//用数组展示 可排序列
          		sortname : 'id', 
          		//显示当前网格数据条数
          		viewrecords : true, 
          		//排序方式 
          		sortorder : "desc", 
          		//multiselect: true,
          		altRows: true,  
                  rownumbers: true,
          		//编辑完成后向台提交
          		editurl : "/RowEditing", 
          		//网格标题
          		caption : "往来单位信息",
          		//网格双击事件
          		ondblClickRow: function (id){  
          			//id为当前行的 index
          			var rowData = $("#callbackgrid_1").jqGrid("getRowData",id);
          			//回填网格设置往来单位id
          			$("#supplierCustomerId").val(rowData.supplierCustomerId); 
          			//回填网格设置往来单位名称
          			$("#supplierCustomerName").val(rowData.supplierCustomerName); 
          			//回填网格设置往来单位类型
          			//$("#supplierCustomerType").val(rowData.supplierCustomerType); 
          			//$("#supplierCustomerTypeName").val(rowData.supplierCustomerType == true ? "供应商" : "客户");
          			$("#supplierCustomerTypeName").val(rowData.supplierCustomerTypeName);
          			$("#supplierCustomerType").val(rowData.supplierCustomerType);
          			//回填网格备注
          			$("#remark").val(rowData.remark); 
          			
          			$("#myModal_1").modal('hide');
          		}
          	}); 
          	// 配置jqgrid 下方的导航信息
          	jQuery("#callbackgrid_1").jqGrid('navGrid', "#callbackpager_1", { edit : false, add : false, del : true, position: "left" },{},{},{},{multipleSearch:true});  
          	//下方为  官方API 示例  http://blog.mn886.net/jqGrid/
          	 //$("#callbackgrid").closest(".ui-jqgrid-bdiv").css({ 'overflow-x' : 'scroll' });
          };
    	 });
     
     </script>

    <!--<div th:replace="/department/model::modelDiv"></div>-->
    <!-- <js th:replace="/eng/materialalias/add/businessJs::businessJs"></js> -->
</th:block>
</body>
</html>